﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 备忘录模式
{
    public class Student
    {
        private string _name;
        private int _age;
        private string _sex;

        public Student(string name, int age, string sex)
        {
            _name = name;
            _age = age;
            _sex = sex;
        }

        public void SetStudent(Memento m)
        {
            this.Name = m.State.Name;
            this.Age = m.State.Age;
            this.Sex = m.State.Sex;
        }

        public Memento CreateMemnto()
        {
            State state = new State();
            state.Name = this.Name;
            state.Age = this.Age;
            state.Sex = this.Sex;
            return new Memento(state);
        }

        public override string ToString()
        {
            return Name + " " + Age + " " + Sex;
        }

        public string Name { get => _name; set => _name = value; }
        public int Age { get => _age; set => _age = value; }
        public string Sex { get => _sex; set => _sex = value; }
    }
}
